package Day2025_04_10;

import java.util.Scanner;

public class Demo02 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt(), b = in.nextInt();
        int ret = 0;
        if (b <= 10) System.out.println(0);
        else {
            if (a <= 10) a = 11;
            for (int i = a; i <= b; i++) {
                String s = i + "";
                int n = s.length();
                int[] arr = new int[n];
                for (int j = 0; j < n; j++) {
                    arr[j] = Integer.parseInt(s.charAt(j) + "");
                }
                int tmp = 0;
                for (int j = 0; j < n; j++) {
                    if (arr[j] == 0) continue;
                    for (int k = 0; k < n; k++) {
                        if (j == k) continue;
                        tmp = arr[j] * 10 + arr[k];
                        if (isNum(tmp)) {
                            ret++;
                            break;
                        }
                    }
                    if (isNum(tmp)) {
                        break;
                    }
                }
            }
            System.out.println(ret);
        }
    }
    private static boolean isNum (int num) {
        if (num == 1 || num == 2) return false;
        for (int i = 2; i <= (int) Math.pow(num, 0.5); i++) {
            if (num % i == 0) return false;
        }
        return true;
    }
}
